<template>
  <div>
    <div class="abab" >
      <span>当前商品数量：</span>
      <el-button type="info" >{{this.GoodNum}}</el-button>
    </div>
    <div class="abab" >
      <span>当前品牌数量：</span>
      <el-button type="success" >{{this.BrandNum}}</el-button>
    </div>
    <div class="abab" >
      <span>当前管理员数量：</span>
      <el-button type="primary" >{{this.UserNum}}</el-button>
    </div>
    <div class="msg">仅显示最近十五条消息</div>
    <el-table
    :data="logList"
    stripe
    style="width: 100%">
    <el-table-column type="index" label="id"></el-table-column>
    <el-table-column
      prop="username"
      label="用户名"
      width="180">
    </el-table-column>
    <el-table-column
      prop="logintime"
      label="发生时间">
    </el-table-column>
    <el-table-column
      prop="status"
      label="状态">
      <template scope="scope">
        <el-button type="primary" size="mini" v-if="scope.row.status==true">成功</el-button>
        <el-button type="danger" size="mini" v-else>失败</el-button>
      </template>
    </el-table-column>
    <el-table-column
      prop="message"
      label="详情信息">
    </el-table-column>
  </el-table>
  </div>
</template>
<script>
export default {
  data () {
    return {
      query: {
        limit: 15
      },
      logList: [],
      GoodNum: '',
      BrandNum: '',
      UserNum: ''
    }
  },
  created () {
    this.getLog()
    this.getGood()
    this.getBrand()
    this.getUser()
  },
  methods: {
    async getLog () {
      const { data: res } = await this.$http.post('log/selectLog', this.query)
      if (res.status !== '200') {
        return this.$message.error('错误')
      }
      this.logList = res.data
    },
    async getGood () {
      const { data: res } = await this.$http.get('good/selectCount')
      if (res.status !== '200') {
        return this.$message.error('错误')
      }
      this.GoodNum = res.data
    },
    async getBrand () {
      const { data: res } = await this.$http.get('brand/selectCount')
      if (res.status !== '200') {
        return this.$message.error('错误')
      }
      this.BrandNum = res.data
    },
    async getUser () {
      const { data: res } = await this.$http.get('user/selectCount')
      if (res.status !== '200') {
        return this.$message.error('错误')
      }
      this.UserNum = res.data
    }
  }
}
</script>
<style lang="less">
.abab{
    width: 200px;
    height: 100px;
    color: black;
    text-align: center;
    margin-left: 140px;
    float: left;
    margin-bottom: 10px;
    .el-button{
      margin-top: 10px;
      width: 130px;
    }
  }
  .msg{
    margin-top: 10px;
    clear: both;
  }
</style>
